package com.lagou.cl.pojo;

import java.io.IOException;
import java.io.InputStream;


public class Request {

	private String method;

	private String url;

	private String host;

	private InputStream inputStream;


	public Request() {
	}

	public Request(InputStream inputStream) throws IOException {
		this.inputStream = inputStream;

		int available = 0;
		while (available == 0) {
			available = inputStream.available();
		}
		byte[] bytes = new byte[available];
		inputStream.read(bytes);

		String resStr = new String(bytes);
		System.out.println("\n接受到请求：\n" + resStr);

		String[] split = resStr.split("\n");
		String[] methodDatas = split[0].split(" ");
		this.method = methodDatas[0];
		this.url = methodDatas[1];

		String[] host = split[1].split(":");
		this.host = host[1].trim();
	}


	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}


	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}

}
